home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / Storage / Alternate container suite < prev    next >
Encoding:
Text File  |  1995-12-15  |  3.1 KB  |  69 lines  |  [TEXT/ttxt]

  1. OpenDocâ„¢ Recipes
  2.  
  3. Using an alternate container suite
  4. By The OpenDoc Design Team
  5. August 1, 1995
  6.  
  7.  
  8. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  9. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  10. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  11.  
  12.  
  13. Container Suite
  14.  
  15. OpenDoc Storage System is designed to work with multiple container suites. The Bento Container Suite is going to be shipped with OpenDoc 1.0. However, other vendors (besides the platform implementor) may want to provide alternate container suites.
  16.  
  17.  
  18. Creating a container
  19.  
  20. In order to create a container, the client has to call the following ODStorageSystem method:
  21.  
  22. ODContainer CreateContainer(in ODContainerType containerType, in ODContainerID id);
  23.  
  24. The first parameter of the method identifies the type of the container. In order to create a Bento file container, the in parameter needs to be kODBentoFileContainer and the second parameter the FSSpec of the file where the container is to be created.
  25.  
  26. This binding is done at runtime. OpenDoc Binding scans the Editors folder(s) for container suite libraries. Each container suite library contains a 'nmap' resource which lists the type(s) of containers that the container suite can create. OpenDoc Binding then caches this information and uses it to determine which container suite library to use when ODStorageSystem::CreateContainer is called.
  27.  
  28. The following is the 'nmap' resource of the Bento Container Suite as defined in a private resource file:
  29.  
  30. #define kNMAPid1 128
  31. #define kODBentoFileContainer  "Apple:Bento:ContainerType:File"
  32. #define kODBentoMemoryContainer  "Apple:Bento:ContainerType:Memory"
  33. #define kODFileContainerID    "ODFileContainer"
  34. #define kODMemoryContainerID   "ODMemContainer"
  35. // kODNameMappings, kODContainerSuite and kODIsAnISOString are defined by OpenDoc.
  36. // They can be found in StdDef.r.
  37.  
  38. resource kODNameMappings (kNMAPid1) {
  39.  kODContainerSuite,
  40.  { /* array Types: 2 elements */
  41.   /* [1] */
  42.   kODBentoFileContainer,
  43.   kODIsAnISOString { 
  44.     kODFileContainerID
  45.   },
  46.   /* [2] */
  47.   kODBentoMemoryContainer,
  48.   kODIsAnISOString { 
  49.     kODMemoryContainerID
  50.   }
  51. };
  52.  
  53. As it is outlined in the resource, the Bento Container Suite can create two kinds of containers -- file and memory.
  54.  
  55. Other container suite providers need to include this 'nmap' resource into their container suite libraries. Otherwise, their container suite will never be bound and created.
  56.  
  57.  
  58. Acquiring a container
  59.  
  60. The process of acquiring a container is almost the same as creating a container. The following ODStorageSystem method is used to acquire a previously created container:
  61.  
  62. ODContainer AcquireContainer(in ODContainerType containerType, in ODContainerID id);
  63.  
  64. The same process takes place to bind the container suite library for the container type supplied.
  65.  
  66.  
  67. Default container type
  68.  
  69. In OpenDoc 1.0, the default container types are interpreted as the Bento container types. Therefore, supplying kODDefaultFileContainer to AcquireContainer or CreateContainer will result in a Bento file container being instantiated. Similarly, supplying kODDefaultMemoryContainer to the same methods will result in a Bento memory container being  instantiated.